/**
 * signals2.c : Demonstrate how to use signals
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

void catch1(int signum);

int main(int argc, char **argv)
{
	struct sigaction act;

	/* Install signal handler
	 * To see signals avaliables, please
	 * see manual pages for kill (man kill).
	 */
	act.sa_handler  = catch1;
	act.sa_restorer = NULL;
	sigaction(SIGTSTP, &act, NULL);

	printf("\nI'am waiting for the signal...\n");
	fflush(stdout);
	while(1);

	return;
}


/**
 * handler for signal 
 */
void catch1(int signum)
{
	if(signum == SIGTSTP) {
		printf(" Catch you =:O\n");
		fflush(stdout);
	}
}

